<?php
error_reporting(0);
session_start();
include_once '../comm/config.php';
include_once '../comm/checkpostandget.php';
include_once 'check.php';
include_once '../comm/wjt.php';
include_once '../comm/msgset.php';
include("upload.class.php");
$CONF['jpeg_enable']   = '1';
$CONF['gif_enable']   = '1';
$CONF['png_enable']   = '1';
function extend_2($file_name)   
{   
$extend = pathinfo($file_name);   
$extend = strtolower($extend["extension"]);   
return $extend;   
} 
$yzm=$_POST['yzm']; 
$id=(int)$_POST["id"]; 
$trade_id=$_POST["jyh"]; 
$trade_id_left=substr($trade_id,0,5);
$trade_id_right=substr($trade_id,-4);
if($yzm==""||$yzm!=$_SESSION["code"])
{
	echo "<script language=javascript>window.location='error.php?id=15';</script>";
	exit;
}
else
{	
    $sql="select * from ".$BIAOTOU."tradelist where Id='".$id."' and (outer_code='' or outer_code is NULL ) and checked=0";
	$rs = mysql_query($sql);
		
	while($row = mysql_fetch_object($rs)) {
		$tbjyh=$row->trade_id; 
		$fxje=ck_fxje(($row->commission),$_SESSION["dduserlevel"]);
		$tgje=round(($row->commission)*TGBL,2); 
		$tbjyh_left=substr($tbjyh,0,5);
		$tbjyh_right=substr($tbjyh,-4);
	}
	if(($trade_id_left==$tbjyh_left)&&($trade_id_right==$tbjyh_right)){
		if(extend_2($_FILES['up_pic']['name'])=="gif"||extend_2($_FILES['up_pic']['name'])=="jpg"||extend_2($_FILES['up_pic']['name'])=="png"||extend_2($_FILES['up_pic']['name'])=="jpeg"){
			if($_POST['vp']){
				$prefix='pic_'.time().mt_rand(1,99999);
				$f_upload = new upload_file($prefix,"php,exe,rar,txt",'../upload/ddjt',512,$_FILES['up_pic']['type']);         
				$f_upload->set_file_name_size($_FILES['up_pic']['name'],$_FILES['up_pic']['size']);
				$f_upload->set_upfile($_FILES['up_pic']['tmp_name']); 
				$file_name = $f_upload->do_save();
			}
			if ($file_name) {
				$sql = "update " . $BIAOTOU . "tradelist set checked=1,ddjt='".$file_name."' where trade_id='" . $tbjyh . "'";
				mysql_query($sql);
				$sj = date("Y-m-d H:i:s");
				//交易列表增加确认人
				$sql = "update " . $BIAOTOU . "tradelist set outer_code='" . $_SESSION["dduserid"] . "',qrsj='" . $sj . "',fxje=" . $fxje . " where id='" . $id . "' and (outer_code='' or outer_code is NULL )";
				mysql_query($sql);
			}
			else{
				echo "<script language=javascript>window.location='error.php?id=29';</script>";//图片上传错误
				exit;
			}		    
			$msg="订单已提交，请等待审核！";
		}
		else{
			echo "<script language=javascript>window.location='error.php?id=16';</script>";
			exit;
		}
	}else{
		echo "<script language=javascript>window.location='error.php?id=16';</script>";
		exit;
    }		

$tag="center";
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<title>找回订单 - 用户中心</title>
<link href="../css/usercss.css" rel="stylesheet" type="text/css">
<link href="../template/<?=MOBAN?>/css/common.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="../js/jquery.js"></script>
</head>

<body id="tradelist">
<?php
include("../template/".MOBAN."/header.tpl.php");
?>
<?php
include("../template/".MOBAN."/nav.tpl.php");
?>
<div id="main">
<?php
include("left.php");
?>
<div class="contain">
  <h2 class="left_nav2">找回订单</h2>
    <div class="order">
    <div class="content" style="font-size:12px; height:200px;">
  <table width="680" border="0" align="center" cellpadding="0" cellspacing="0">
                        <tr>
                          <td height="145" colspan="3" align="center">&nbsp;<?=$msg?></td>
                        </tr>
        </table>
</div>
	</div>
</div>
</div>
<?php
include("../template/".MOBAN."/footer.tpl.php");
?>
</body>
</html>